/*
 * @Author: 天羽落星辰
 * @Date: 2020-08-26 09:55:53
 * @LastEditors: 天羽落星辰
 * @LastEditTime: 2020-08-26 19:07:46
 * @Description: file content
 */
define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'bhd/index' + location.search,
                    add_url: 'bhd/add',
                    edit_url: 'bhd/edit',
                    del_url: 'bhd/del',
                    multi_url: 'bhd/multi',
                    table: 'bhd',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                columns: [
                    [
                        {checkbox: true},
                        // {field: 'id', title: __('Id')},
                        {field: 'uname', title: __('Uname')},
                        // {field: 'uid', title: __('Uid')},
                        {field: 'money', title: __('Money'), operate:'BETWEEN', formatter: function (value,row) {return value * 1}},
                        // {field: 'hash', title: __('Hash'),
                        // formatter: function (value,row) {
                        //     if(value){
                        //         return '<a title="'+ value +'" target="view_window" href="https://tokenview.com/cn/search/' + value + '">' +  __('Hash') + '</a>';
                        //     }
                        // }},
                        {field: 'address', title: __('Address')},
                        {field: 'status', title: __('Status'), formatter: Table.api.formatter.status, searchList: {1: __('成功'),2: __('审核中'),3: __('作废')}},
                        {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
                        {field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
                        {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});